import http from '../utils/http';

interface LoginParams {
  username: string;
  password: string;
}

interface LoginResponse {
  token: string;
  // userInfo: {
  //   id: string;
  //   name: string;
  //   role: string;
  // };
}

export const login = async (params: LoginParams): Promise<LoginResponse> => {
  try {
    const response = await http.post('/auth/login', params);
    return response.data;
  } catch (error) {
    throw new Error('登录失败，请检查用户名或密码');
  }
};
